<template>
  <van-nav-bar :title="title" left-arrow @click-left="onClickLeft" @click-right="onClickRight">
    <van-icon name="home" slot="right" />
  </van-nav-bar>
</template>

<script>
import { NavBar, Toast } from 'vant'

export default {
  props: ['title','shopindex'],
  components: {
    [NavBar.name]: NavBar,
    [Toast.name]: Toast
  },
  data(){
    return {
      activeIndex:-1
    }
  },
  created(){
    // console.log(this.shopindex);
    this.activeIndex = this.shopindex;
  },
  methods: {
    onClickLeft() {
      console.log(this.activeIndex);
      if(this.activeIndex&&this.activeIndex>0){
        this.$router.push({path:'/shop',query:{currentindex:this.activeIndex}})
      }else{
        this.$router.back()
      }

    },

    onClickRight() {
      this.$router.push('/home')
    }
  }
}
</script>

<style>

</style>
